﻿ #define _CRT_SECURE_NO_WARNINGS 1

class Solution
	 {
 public:
	 int lastStoneWeight(vector<int>&stones)
		 {
		 // 1. 创建⼀个⼤根堆
			 priority_queue<int> heap;
		 // 2. 将所有元素丢进这个堆⾥⾯
			 for (auto x : stones) heap.push(x);
		 // 3. 模拟这个过程
			 while (heap.size() > 1)
			 {
			 int a = heap.top(); heap.pop();
			 int b = heap.top(); heap.pop();
			 if (a > b) heap.push(a - b);
			 }
		
			 return heap.size() ? heap.top() : 0;
		 }
	 };